# TODO: Add comment
# 
# Author: ryan
###############################################################################

#rm(list=ls());
# load qcc package.
library(qcc);
#windows();
graphics.off();

setwd("C:/carmd-cvs02/Koala");

png(filename="./DynamicWebPage/ProcessCapabilityChart.png",width = 450, height = 300);
# read limits
#limits<-read.table("C:/carmd-cvs01/Data_Parser/DataSource/ProcessCapability-limits.txt",header=TRUE);
limits<-read.table(	"./DataSource/ProcessCapability-limits.txt",
					header=TRUE,na.strings="NA");
attach(limits);
if (is.na(t)) t=NULL;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
# read source data
datasource<-read.table(	"./DataSource/ProcessCapability.txt",
						header=TRUE,
						na.strings="NA");
# get the header name, will be used as the title of the chart.
attach(datasource);
ChartTitle<-names(datasource[1]);

#obj<-qcc(datasource,type="xbar.one",title=names(datasource[1]),target=t);
obj<-qcc(	datasource,type="xbar.one",target=t,data.name=names(datasource[1]));

#qcc.options(beyond.limits$pch="red");
qcc.options(font.stats = 1, cex.stats = 0.8, cex=0.8,
			bg.margin="lightblue",bg.figure="lightyellow");

process.capability(obj,spec.limits=c(lsl,usl));

dev.off();
